package sentinel.demo01;

import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.ArrayList;
import java.util.List;

@SpringBootApplication
public class Demo01Main {
    public static void main(String[] args) {
        SpringApplication.run(Demo01Main.class,args);
        //加载绑定到sayHi01资源的唯一规则
        List<FlowRule> flowRules=new ArrayList<>();
        //只有一个元素 FlowRule绑定sayHi01
        FlowRule flowRule=new FlowRule();
        //3个规则属性必要的
        flowRule.setResource("sayHi01");//绑定哪个资源
        flowRule.setCount(1); //流量访问的上限阈值
        flowRule.setGrade(1);//流量的控制维度 0 并发限流 1 qps限流
        flowRules.add(flowRule);
        //sentinel 读取规则数据
        FlowRuleManager.loadRules(flowRules);
    }
}
